package org.jeecg.jxc.base.supplier.service;


import cn.hutool.db.PageResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.jeecg.jxc.base.goods.vo.PageVo;
import org.jeecg.jxc.base.supplier.entity.PageVO;
import org.jeecg.jxc.base.supplier.entity.ServiceVO;
import org.jeecg.jxc.base.supplier.entity.Supplier;
import org.jeecg.jxc.base.supplier.mapper.SupplierMapper;
import org.springframework.data.repository.query.ResultProcessor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @author: 咕咚
 * @date: 2022.04.26 15:53
 * 项目名称：jeecg-boot-parent
 * 版本号：1.0
 */
@Service
public class SupplierService {

    @Resource
    private SupplierMapper supplierMapper;

    @Transactional(readOnly = true)
    public List<Supplier> page(Integer page, Integer rows, String supplierName) {
        List<Supplier> result = supplierMapper.pages(page*(page-1), rows, supplierName);

        return result;
    }

    public Integer count(Integer page, Integer rows, String supplierName) {
        return supplierMapper.count(page, rows, supplierName);
    }

    public ServiceVO addSupplier(Supplier supplier) {
        int i = supplierMapper.addSupplier(supplier);
        if (i==0){
            return new ServiceVO("50","请求失败",null);
        }
        return new ServiceVO("100","请求成功",null);
    }

    public ServiceVO deleteSuplierById(Integer ids) {
        int i = supplierMapper.delete(ids);
        if (i==0){
            return new ServiceVO("50","请求失败",null);
        }
        return new ServiceVO("100","请求成功",null);

    }

    public ServiceVO updateSupplierById(Integer supplierId,Supplier supplier) {
        int i = supplierMapper.updateById(supplierId, supplier);
        if (i==0){
            return new ServiceVO("50","请求失败",null);
        }
        return new ServiceVO("100","请求成功",null);
    }
}
